<template>
  <div class="wrapper">
    <div class="title">
      <img src="../../assets/img/logintitle-1.png"
           alt="登录标题" /><span>党建管理系统</span>
    </div>
    <div class="icon">
      <img src="../../assets/img/loginicon.png"
           alt="登录标题" />
    </div>
    <div class="login-box">
      <!-- JCryption表单提交 -->
      <div class="login-box__left">
        <!-- <div class="box__userName">
          <el-input id="userName"
                    v-model.trim="userName"
                    placeholder="请输入手机号/身份证号/账号"
                    :autofocus="true"
                    @keypress.enter.native="sumitForm"
                    class="box__userName_input"></el-input>
          <img src="../assets/icon/username.png"
               class="box__userName_img"
               alt="" />
        </div>
        <div class="box__password">
          <el-input id="password"
                    v-model.trim="password"
                    type="password"
                    placeholder="请输入密码"
                    @keypress.enter.native="sumitForm"
                    class="box__password_input"></el-input>
          <img src="../assets/icon/password.png"
               class="box__password_img"
               alt="" />
        </div> -->
        <el-form ref="form"
                 :model="formValidate"
                 :rules="ruleValidate">
          <el-form-item label=""
                        prop="userAccount">
            <el-input v-model="formValidate.userAccount"
                      placeholder="请输入账号"
                      prefix-icon="el-icon-user-solid"></el-input>
          </el-form-item>
          <el-form-item label=""
                        prop="password">
            <el-input v-model="formValidate.password"
                      placeholder="请输入密码"
                      type='password'
                      prefix-icon="el-icon-s-grid"></el-input>
          </el-form-item>
        </el-form>
        <el-button id="loginEle"
                   class="login-box_button"
                   type="primary"
                   @click="login()">登录</el-button>
      </div>
    </div>
  </div>
</template>

<script>
// import "@static/plugins/jquery.form";
// import "@static/plugins/jquery.jcryption.3.1.0";
// import loginApi from "../api/login/login";
import store from "../../store";
export default {
  name: "login",
  data () {
    return {
      loading: false,
      // loginBtn: false,
      // currentFilePath: "",
      // uuid: "",
      // codeImage: "",
      // userName: "",
      // password: "",
      authCode: "",
      formValidate: {
        userAccount: '',
        password: ''
      },
      ruleValidate: {
        userAccount: [{
          required: true,
          message: '账号不能为空',
          trigger: 'change'
        }],
        password: [{
          required: true,
          message: '密码不能为空',
          trigger: 'change'
        }]
      }
    };
  },
  methods: {
    login () {
      this.$refs.form.validate((valid) => {
        if (!valid) return
        this.loading = true
        this.$Ajax(
          "/login",
          "post",
          this.formValidate,
          (res) => {
            store.commit('SET_TOKEN', res.data.authToken)
            store.commit("SET_USER_INFO", res.data);
            localStorage.setItem('userInfo', JSON.stringify(res.data))
            this.$Ajax(
              "/systemMenu/listMyMenu",
              "get",
              {},
              (res) => {
                this.loading = false
                store.commit('SET_MENU', res.data)
                this.$router.replace(res.data[0].children[0].children[0].linkUrl)
              }
            )
          }
        )
      })
    }
  },
};
</script>

<style lang="scss" scoped>
.wrapper {
  min-height: 100vh;
  overflow-x: hidden;
  background: url(../../assets/img/loginbg.png) no-repeat center center;
  background-size: 100% 100%;
  box-sizing: border-box;
}
.icon {
  width: 100%;
  text-align: center;
  img {
    width: 76%;
  }
}
.title {
  width: 100%;
  // text-align: center;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin: 100px 0 80px 0;
  img {
    width: 192px;
    // height: 60px;
    display: inline-block;
  }
  span {
    margin-left: 10px;
    display: inline-block;
    font-size: 64px;
    font-weight: 600;
    line-height: 72px;
    color: #cc181f;
  }
}
.header {
  width: 1200px;
  padding: 20px 0;
  margin: 0 auto;
  box-sizing: border-box;
}
.header__logo {
  display: inline-block;
  width: 175px;
  height: 28px;
  margin-right: 16px;
  vertical-align: middle;
}
.header__title {
  display: inline-block;
  vertical-align: middle;
}
.header_next {
  height: 160px;
  vertical-align: middle;
  background: url("../../assets/icon/login_background.png") repeat-x center
    center;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}

.login-box {
  width: 522px;
  box-sizing: border-box;
  padding: 60px 38px 60px;
  margin: 40px auto;
  // border: 1px solid #ce1313;

  box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.4);
  // border-radius:4px;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.25);
  background-origin: padding-box;
  background: url("../../assets/img/login_boxbg.png") repeat-x center center;
}
.login-box__left {
  // float: left;
  // margin-top: 10px;
  margin: 0 auto;
}
.login-box__title {
  margin: 0 0 30px 0;
  font-size: 16px;
  font-weight: bold;
  color: rgba(0, 0, 0, 0.85);
}
.box__userName {
  position: relative;
}
.login-box__tip {
  height: 24px;
  line-height: 24px;
  color: #b81c24;
  font-size: 12px;
}
.box__userName_img {
  position: absolute;
  display: block;
  top: 10px;
  left: 12px;
  // width: 16px;
  // height: 16px;
}
.box__password_img {
  // extend(.box__userName_img)
  position: absolute;
  display: block;
  top: 10px;
  left: 12px;
}
.box__password {
  position: relative;
  margin: 0 0 0 0;
}
.box__authCode {
  display: flex;
  margin: 0 0 0 0;
  position: relative;
}
.validCode__box {
  width: 150px;
  height: 38px;
  cursor: pointer;
  margin-left: 10px;
  margin-top: 4px;
  img {
    width: 100%;
  }
}
.authCode {
  flex: 1;
}
.login-box_button {
  width: 100%;
  height: 46px;
  margin-top: 16px;
  background-color: #ff4d4f;
  border-radius: 20px;
  font-size: 20px;
  // line-height:46px;
}
/deep/.box__userName_input .el-input__inner {
  padding: 0 15px 0 45px;
  font-size: 19px;
  font-weight: 600;
  background-color: transparent;
  height: 46px;
  line-height: 40px;
  // border: 1px solid #ce1313;
  border: none;
  border-bottom: 1px solid #cbcbcb;
  width: 100%;
  &:focus {
    border-bottom: 1px solid #ff4d4f;
  }
}
/deep/.box__password_input .el-input__inner {
  padding: 0 15px 0 45px;
  font-size: 19px;
  font-weight: 600;
  background-color: transparent;
  height: 46px;
  line-height: 40px;
  // border: 1px solid #ce1313;
  border: none;
  border-bottom: 1px solid #cbcbcb;
  width: 100%;
  &:focus {
    border-bottom: 1px solid #ff4d4f;
  }
}
/deep/.box__authCode_input .el-input__inner {
  padding: 0 15px 0 45px;
  font-size: 19px;
  font-weight: 600;
  background-color: transparent;
  height: 46px;
  line-height: 40px;
  // border: 1px solid #ce1313;
  border: none;
  border-bottom: 1px solid #cbcbcb;
  width: 320px;
  &:focus {
    border-bottom: 1px solid #ff4d4f;
  }
}

.login-box__middle {
  float: left;
  margin: 30px 30px 0 45px;
  width: 1px;
  height: 249px;
  background: rgba(0, 0, 0, 0.09);
}
.login-box__right {
  float: left;
}
.login-box__right__title {
  text-align: center;
  width: 245px;
  margin: 0 0 20px 0;
  font-size: 14px;
  color: #b81c24;
}
.link {
  position: relative;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 243px;
  background: linear-gradient(
    180deg,
    rgba(221, 60, 74, 1) 0%,
    rgba(184, 28, 36, 1) 100%
  );
  .ft {
    background: #ca313f;
    position: relative;
    width: 100%;
    height: auto;
    .box {
      width: 1440px;
      display: flex;
      box-sizing: border-box;
      justify-content: space-between;
      line-height: 56px;
      margin: 0 auto;
      padding-left: 117px;
      color: #fbeff0;
      font-size: 14px;
    }
  }
}
.link__container {
  display: flex;
  width: 1440px;
  box-sizing: border-box;
  padding: 32px 0 0 120px;
  margin: 0 auto;
}
.link__container__dl {
  width: 25%;
  padding-left: 30px;
  box-sizing: border-box;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  &:first-child {
    padding-left: 0;
  }
  &:last-child {
    border-right: none;
  }
}
.link__container__dt {
  color: #ffffff;
  margin: 0 0 12px 0;
}
.link__container__dd {
  margin: 0 0 10px 0;
}
.link__container__dd_title {
  color: #ffffff;
  opacity: 0.7;
  font-size: 14px;
  text-decoration: none;
}
.link__container__dd_logo {
  width: 116px;
  height: 116px;
  box-sizing: border-box;
  border: 6px solid rgb(177, 93, 93);
  border-radius: 50%;
  padding-top: 17px;
  background: #fff;
  img {
    display: block;
    width: 73px;
    height: 73px;
    margin: 0 auto;
  }
}
</style>
